<script>
    function pageInit() {        
        //父节点下拉初始化
        ParentSelectInit('{{.parent}}');
		$('#Rtype').val('{{.m.Rtype}}')
		
    }
	pageInit(); 
    function ParentSelectInit(curPid){
        var url = '{{urlfor "ResourceController.ParentTreeGrid"}}'
        $.post(url, { id: $("#Id").val() }, function (re) {
            if (re.code === 0) {
                var html = ['<option value="0">- 无 -</option>']
                var $select = $("#Parent");
                $select.html('')
                $(re.data).each(function (i, e) {
                    //下拉菜单里只显示区域和菜单
                    if(e.Rtype >1){
                        return true
                    }
                    var str = new Array(e.Level * 4).join("&nbsp;");
                    if (e.Level > 0)
                        str = str + "|-";
                    html.push('<option value="' + e.Id + '"');
                    if (e.HtmlDisabled == 1) {
                        html.push('disabled');
                    }
                    html.push('>' + str + e.Name + '</option>')
                });
                $select.html(html.join(''));
                $select.val(curPid);
            } else {
                layer.alert("获取资源树失败", { icon: 2, title: '失败' })
            }
        });
    }
</script>